import 'package:im_demo/app/data/chat/api/bigInt_converter.dart';
import 'package:json_annotation/json_annotation.dart';

part 'login_response.g.dart';

@JsonSerializable(explicitToJson: true, anyMap: true)
class LoginResponse {
  // @BigIntConverter()
  final int userId;

  // @BigIntConverter()
  final int? deptId;

  final String token;

  // @BigIntConverter()
  final int loginTime;

  // @BigIntConverter()
  final int? expireTime;
  final String? ipaddr;
  final String? loginLocation;
  final String? browser;
  final String? os;
  final List<String>? permissions;
  final LoginResponseUserResp userResp;
  final bool enabled;
  final String? password;
  final String? username;
  final List<LoginAuthorities>? authorities;
  final bool accountNonExpired;
  final bool accountNonLocked;
  final bool credentialsNonExpired;

  LoginResponse(
    this.userId,
    this.deptId,
    this.token,
    this.loginTime,
    this.expireTime,
    this.ipaddr,
    this.loginLocation,
    this.browser,
    this.os,
    this.permissions,
    this.userResp,
    this.enabled,
    this.password,
    this.username,
    this.authorities,
    this.accountNonExpired,
    this.accountNonLocked,
    this.credentialsNonExpired,
  );

  factory LoginResponse.fromJson(Map<String, dynamic> json) =>
      _$LoginResponseFromJson(json);

  Map<String, dynamic> toJson() => _$LoginResponseToJson(this);
}

@JsonSerializable(explicitToJson: true, anyMap: true)
class LoginResponseUserResp {
  final int? id;
  final String? username;
  final String? password;
  final String? phone;

  LoginResponseUserResp(this.id, this.username, this.password, this.phone);

  factory LoginResponseUserResp.fromJson(Map<String, dynamic> json) =>
      _$LoginResponseUserRespFromJson(json);

  Map<String, dynamic> toJson() => _$LoginResponseUserRespToJson(this);
}

@JsonSerializable(explicitToJson: true, anyMap: true)
class LoginAuthorities {
  final String authority;

  LoginAuthorities(this.authority);

  factory LoginAuthorities.fromJson(Map<String, dynamic> json) =>
      _$LoginAuthoritiesFromJson(json);

  Map<String, dynamic> toJson() => _$LoginAuthoritiesToJson(this);
}
